package com.lkd.controller;

import com.lkd.dto.VmTypeDto;
import com.lkd.entity.VmType;
import com.lkd.service.IVmTypeService;
import com.lkd.vo.PageBean;
import com.lkd.vo.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName: VmTypeController
 * Package: com.lkd.controller
 * Description:
 *
 * @Author zt
 * @Create 2025/10/16 16:40
 * @Version 1.0
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vm-service/vmType")
public class VmTypeController {

    private final IVmTypeService vmTypeService;
    /**
     * 设备类型搜索
     */
    @GetMapping("/search")
    public Result search(VmTypeDto vmTypeDto){
        PageBean<VmType> pageBean = vmTypeService.search(vmTypeDto);
        return Result.success(pageBean);
    }

    /**
     * 新增设备
     */
    @PostMapping
    public Result saveVmType(@RequestBody VmType vmType){
        boolean save = vmTypeService.save(vmType);
        return Result.success(save);
    }

    /**
     * 修改设备类型
     */
    @PutMapping
    public Result updateVmType(@RequestBody VmType vmType){
        boolean updated = vmTypeService.updateById(vmType);
        return Result.success(updated);
    }

    /**
     * 删除设备类型
     */
    @DeleteMapping("/{typeId}")
    public Result deleteVmType(@PathVariable Integer typeId){
        boolean removed = vmTypeService.removeById(typeId);
        return Result.success(removed);
    }


}
